<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3463：[COCI2012] Inspector</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[COCI2012] Inspector</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[COCI2012] Inspector</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [COCI2012] Inspector                </h1>
                <p>时间限制：40s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：256MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p><span style="font-size: medium"><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning />
<w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
<w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
<w:ValidateAgainstSchemas />
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:SpaceForUL />
<w:BalanceSingleByteDoubleByteWidth />
<w:DoNotLeaveBackslashAlone />
<w:ULTrailSpace />
<w:DoNotExpandShiftReturn />
<w:AdjustLineHeightInTable />
<w:BreakWrappedTables />
<w:SnapToGridInCell />
<w:WrapTextWithPunct />
<w:UseAsianBreakRules />
<w:DontGrowAutofit />
<w:UseFELayout />
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--></span></p>
<p><span style="font-size: medium"><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体">在一个小国家中，一个新的小镇终于建成了！如往常一样，</span><span lang="EN-US">Mirko</span><span style="font-family: 宋体">获得了&ldquo;首席税务巡查员&rdquo;的职位。他的任务是保证正确地计算各公司的收入情况。一共有</span><span lang="EN-US">N</span><span style="font-family: 宋体">家办公室坐落在主干道上，从左到右被编号为</span><span lang="EN-US">1~N</span><span style="font-family: 宋体">。一开始，所有办公室一开始都是空的。随后，一些公司会搬入或搬出某些办公室。</span><span lang="EN-US">Mirko</span><span style="font-family: 宋体">时不时地会经过某些办公室并审查在这些办公室中，最富有的公司的账目。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体">一个公司被以如下的方式描述：</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">T-</span><span style="font-family: 宋体">表示搬入的第一天。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">K-</span><span style="font-family: 宋体">表示搬入的办公室的标号。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">Z-</span><span style="font-family: 宋体">公司每日的盈利。（可以是负值表示亏损）</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">S-</span><span style="font-family: 宋体">公司搬入时的公司财务情况。（即公司的账户资金，也可以是负值）</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体">如果一家公司已经在</span><span lang="EN-US"> K </span><span style="font-family: 宋体">办公室了，当有新公司要进入</span><span lang="EN-US"> K </span><span style="font-family: 宋体">办公室时，这家公司会立刻搬出。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体">新公司第一天并不会运营，盈利从第二天开始计算。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">Mirko</span><span style="font-family: 宋体">的审查以</span><span lang="EN-US"> 3 </span><span style="font-family: 宋体">个整数来描述：</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">T-</span><span style="font-family: 宋体">审查的时间。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">A </span><span style="font-family: 宋体">和</span><span lang="EN-US"> B-Mirko</span><span style="font-family: 宋体">会检查</span><span lang="EN-US"> A </span><span style="font-family: 宋体">办公室至</span><span lang="EN-US"> B </span><span style="font-family: 宋体">办公室（包括</span><span lang="EN-US">A</span><span style="font-family: 宋体">和</span><span lang="EN-US">B</span><span style="font-family: 宋体">）之间的公司。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">Mirko</span><span style="font-family: 宋体">只会在一天结束时检查，所有公司这时已经计算完成了当天利润。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">&nbsp;</span></span></p>
<p></p></p><hr/><h3>输入格式</h3><p><p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体"><br />
</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体">第一行包含</span><span lang="EN-US"> 2 </span><span style="font-family: 宋体">个正整数：</span><span lang="EN-US">N</span><span style="font-family: 宋体">（</span><span lang="EN-US">1&lt;=N&lt;=100000</span><span style="font-family: 宋体">）表示办公室的数量和</span><span lang="EN-US">M</span><span style="font-family: 宋体">（</span><span lang="EN-US">1&lt;=M&lt;=300000</span><span style="font-family: 宋体">）表示事件的个数。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体">接下来</span><span lang="EN-US"> M </span><span style="font-family: 宋体">行，遵循以下格式：&ldquo;</span><span lang="EN-US">1 T K Z S</span><span style="font-family: 宋体">&rdquo;或&ldquo;</span><span lang="EN-US">2 T A B</span><span style="font-family: 宋体">&rdquo;（含义如题目描述）。其中</span><span lang="EN-US"> T </span><span style="font-family: 宋体">会严格递增，并且最后一天小于</span><span lang="EN-US"> 1000000,Z </span><span style="font-family: 宋体">和</span><span lang="EN-US"> S </span><span style="font-family: 宋体">的绝对值也严格小于</span><span lang="EN-US"> 1000000</span><span style="font-family: 宋体">。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span style="font-family: 宋体">（注意</span><span lang="EN-US">A</span><span style="font-family: 宋体">可能大于</span><span lang="EN-US">B</span><span style="font-family: 宋体">）</span></span></p>
<p class="MsoNormal"><span style="font-size: medium"><span lang="EN-US">&nbsp;</span></span></p>
<p></p></p><hr/><h3>输出格式</h3><p><p><span style="font-size: medium;"><span style="font-family: 宋体;">对于每次</span><span lang="EN-US">Mirko</span><span style="font-family: 宋体;">的审查，每行输出一个整数，表示当天最富有的公司的资产（可以为负）。如果</span><span lang="EN-US">Mirko</span><span style="font-family: 宋体;">经过的所有办公室中都没有公司入驻，则输出</span><span lang="EN-US">&ldquo;nema&rdquo;</span><span style="font-family: 宋体;">（不加引号）。</span></span></p>
<p class="MsoNormal"><span style="font-size: medium;"><span lang="EN-US">&nbsp;</span></span></p>
<p></p></p><hr/><h3>样例输入</h3><pre>5 9
1 1 5 4 -5
2 2 3 5
1 3 4 6 9
2 4 1 2
1 6 2 2 3
2 8 2 1
1 9 4 0 17
2 10 5 5
2 11 1 4

 

</pre><hr/><h3>样例输出</h3><pre>-1
nema
7
31
17

 

</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>By Jason Hsiao</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3463" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3463" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>